# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html

import json
class Data5UPipeline(object):
    def __init__(self):
        self.file = open("item.json", "w+")
 
    def process_item(self, item, spider):
        record = json.dumps(dict(item), ensure_ascii=False)+"\n"  #此处如果有中文的话，要加上ensure_ascii=False参数，否则可能出现乱码
        self.file.write(record.encode('utf-8')+'\n')
        return item
 
    def open_spider(self, spider):
        pass
 
    def close_spider(self, spider):
        self.file.close()